define(function(){
	function fn(){
		//动态获取页面元素
		$.getJSON('../json/goods.json',function(response,status,xhr){
			//顶部活动区
			$(".active a").attr("href",response[0][0].links).children("img").attr("src","../" + response[0][0].paths);
			//顶部特价
			$(".tejia a").attr("href",response[0][1].links).children("img").attr("src","../" + response[0][1].paths);
			//右侧浮动栏广告
			$(".right_ad img").attr("src","../" + response[0][4].paths);
		})
		//获取二级菜单的json
		$.getJSON('../json/submenu.json',function(response,status,xhr){
			$(".submenu").mouseleave(function(){
				$(".submenu_con_list").empty();
				$(".submenu_con_img").empty();
				$(".submenu_con").css("display","none");
				$(".submenu").css("display","none");
			});
			$(".menu_btn").mouseover(function(){
				$(".submenu").css("display","block");
			})
			$(".all_kind").mouseleave(function(){
				$(".submenu").css("display","none");
			})
			$(".submenu li").mouseenter(function(){
				//清空菜单面板
				$index = $(this).index();
				if($index <= 7){
					$(".submenu_con_list").empty();
					$(".submenu_con_img").empty();
					$(".submenu_con").css("display","block");
					$littleImg = response[$index].littleImg;
					$bigImg = response[$index].bigImg;
					$first = response[$index].first;
					$second = response[$index].second;
					$third = response[$index].third;
					$fourth = response[$index].fourth;
					$fifth = response[$index].fifth;
					//alert($littleImg[1].path);
					if($littleImg.length > 0){
						$(".submenu_con_img").append("<div class='little_img clearfix'></div>");
						for($i = 0;$i < $littleImg.length;$i ++){
							$(".little_img").append("<a href='" + $littleImg[$i].link + "'><img src='../" + $littleImg[$i].path + "'/></a>");
						}
					}
					if($bigImg.length > 0){
						$(".submenu_con_img").append("<div class='big_img clearfix'></div>")
						for($i = 0;$i < $bigImg.length;$i ++){
							$(".big_img").append("<a href='" + $bigImg[$i].link + "'><img src='../" + $bigImg[$i].path + "'/></a>")
						}
					}
					$addEle($first,"first");
					$addEle($second,"second");
					$addEle($third,"third");
					$addEle($fourth,"fourth");
					$addEle($fifth,"fifth");
				}else{
					$(".submenu_con").css("display","none");
				}	
			})			
		})
		function $addEle($m,num){
			if($m){
				$(".submenu_con_list").append("<div class='" + num + "'></div>");
				$("." + num).append("<h2>" + $m[0] + "</h2><p></p>");
				for($i = 0;$i < $m[1].length;$i ++){
					$("." + num + " p").append("<a href='#'>" + $m[1][$i] + "</a>")
				}
			}
		}
	}
	return {
		fn: fn	
	}
})